<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let arr = [{
      pid: '生物',
      children:[{pid:'动物', children:[{pid:'老虎'}]},{pid:'微生物', children:[{pid:'昆虫'}]}]
    }]

    function treeToArr(arr) {
       const [root] = arr.filter(items=>items.pid)
    }
  </script>
</body>
</html>